//
//  DDChargeViewController.m
//  DingDongZP
//
//  Created by weily on 16/5/11.
//  Copyright © 2016年 iyhjiang.com. All rights reserved.
//

#import "DDChargeViewController.h"
#import "DDChargeFootView.h"
#import "DDChargeNumberCell.h"
#import "DDChargeValueCell.h"
#import "DDChargeViewPhoneViewController.h"

@interface DDChargeViewController ()
<UITableViewDataSource,
UITableViewDelegate>
@property (nonatomic, strong) UITableView *tableView;

@end

@implementation DDChargeViewController

- (void)viewDidLoad
{
    [super viewDidLoad];
    
    self.title = @"充值";
    self.view.backgroundColor = COLOR_BACKGROUND;
    
    UITableView *tableView = [[UITableView alloc] initWithFrame:self.view.bounds style:UITableViewStyleGrouped];
    tableView.dataSource = self;
    tableView.delegate = self;
    tableView.separatorStyle = UITableViewCellSeparatorStyleNone;
    tableView.tableFooterView = [UIView new];
    [self.view addSubview:tableView];
    [tableView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.edges.equalTo(self.view);
    }];
    self.tableView = tableView;
    
    [self.tableView registerNib:[UINib nibWithNibName:@"DDChargeNumberCell" bundle:nil] forCellReuseIdentifier:@"numberCell"];
    [self.tableView registerNib:[UINib nibWithNibName:@"DDChargeValueCell" bundle:nil] forCellReuseIdentifier:@"valueCell"];
    [self.tableView registerClass:[DDChargeValueCell class] forCellReuseIdentifier:@"valueCell"];
    self.tableView.tableFooterView = [DDChargeFootView instanciate];
    
    ///	foot view 事件
    __weak typeof(self) weakSelf = self;
    DDChargeFootView *foot = (DDChargeFootView *)self.tableView.tableFooterView;
    foot.callbackPhoneCharge = ^{
        DDChargeViewPhoneViewController *vc = [[DDChargeViewPhoneViewController alloc] init];
        [weakSelf.navigationController pushViewController:vc animated:YES];
    };
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

#pragma mark - table
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
{
    return 2;
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
    return 1;
}

- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
{
    if (indexPath.section == 0) {
        return 55;
    }
    else {
        return 120;
    }
}

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    if (indexPath.section == 0)
    {
        DDChargeNumberCell *cell = [tableView dequeueReusableCellWithIdentifier:@"numberCell"];
        
        return cell;
    }
    else
    {
        DDChargeValueCell *cell = [tableView dequeueReusableCellWithIdentifier:@"valueCell"];
        
        return cell;
    }
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
